// import React from "react";
//
// class App extends React.Component{
//     render() {
//         return (
//             <div className={"bottomApp"}>
//                你吗
//             </div>
//         )
//     }
// }
// export default App;
import React from "react";
import {TabBar} from "antd-mobile";

class App extends React.Component{

    constructor(props) {
        super(props);
        this.state = {
            activeKey: this.getActiveKey(),
            shoppingCarBadge:0
        }
    }

    getActiveKey() {
        if (window.location.pathname === "/") {
            return "";
        } else if (window.location.pathname === "/category") {
            return "category";
        } else if (window.location.pathname === "/shoppingCar") {
            return "shoppingCar";
        } else {
            return "member";
        }
    }



    render() {
        return (
            <div className={"bottomApp"}>

                <TabBar activeKey={this.state.activeKey} onChange={
                    key => {
                        this.props.history.replace("/" + key);
                    }
                }>
                    <TabBar.Item key={""} title={"首页"}
                                 icon={<img src={require("../../asset/image/tabbar/home"+(window.location.pathname === "/" ? "1" : "0")+".png").default} alt={""}/>}/>
                    <TabBar.Item key={"category"} title={"分类"}
                                 icon={<img src={require("../../asset/image/tabbar/category"+(window.location.pathname === "/category" ? "1" : "0")+".png").default} alt={""}/>}/>} />
                    <TabBar.Item key={"shoppingCar"} title={"购物车"}
                                 badge={this.state.shoppingCarBadge}
                                 icon={<img src={require("../../asset/image/tabbar/shoppingcar"+(window.location.pathname === "/shoppingCar" ? "1" : "0")+".png").default} alt={""}/>}/>} />
                    <TabBar.Item key={"member"} title={"我的"}
                                 icon={<img src={require("../../asset/image/tabbar/my"+(window.location.pathname.indexOf("member") > -1 ? "1" : "0")+".png").default} alt={""}/>} />
                </TabBar>
            </div>
        )
    }

}

export default App;
